package com.cndw.kungfu.model.disciple;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.cndw.kungfu.config.ConstantsConfig;
import com.cndw.kungfu.ext.StringProcesser;
import com.cndw.kungfu.ext.XmlProcesser;

/**
 * 徒弟天赋,也就是技能
 * @author fantadust [9677889@qq.com]
 * @date 2011-10-31 下午2:00:32
 */
public class DiscipleDower {
	
	private static Map<Integer, DiscipleDower> dowerMap = new HashMap<Integer, DiscipleDower>();
	/**
	 * 标志id
	 */
	private int id;
	/**
	 * 名称
	 */
	private String name;
	/**
	 * 描述语
	 */
	private String title;
	/**
	 * 加成字符串
	 */
	private String addition;
	/**
	 * 加成数组
	 */
	private int[] add;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getAddition() {
		return addition;
	}
	public void setAddition(String addition) {
		this.addition = addition;
		if (addition != null && addition.length()> 1) {			
			add = StringProcesser.toIntArray(addition);
		}
	}
	public void setAdd(int[] add) {
		this.add = add;
	}
	public int[] getAdd() {
		return add;
	}
	static{
		load();
	}
	
	public static synchronized void load(){
		if (dowerMap.isEmpty()) {
			List<DiscipleDower> dowerList = XmlProcesser.processXml(DiscipleDower.class,ConstantsConfig.getLocaleResource() +"discipleDower.xml");
			for (DiscipleDower dower : dowerList) {
				dowerMap.put(dower.getId(), dower);
			}
		}
	}
	public static DiscipleDower getById(int id){		
		return dowerMap.get(id);
	}
	public static Map<Integer, DiscipleDower> getDowers(){
		return dowerMap;
	}
	
	
}
